home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / uriloader / nsDocLoader.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  8KB  |  235 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1999
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  26.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. /* 
  39. */
  40.  
  41. #ifndef nsDocLoader_h__
  42. #define nsDocLoader_h__
  43.  
  44. #include "nsIDocumentLoader.h"
  45. #include "nsIWebProgress.h"
  46. #include "nsIWebProgressListener.h"
  47. #include "nsIRequestObserver.h"
  48. #include "nsWeakReference.h"
  49. #include "nsILoadGroup.h"
  50. #include "nsCOMArray.h"
  51. #include "nsVoidArray.h"
  52. #include "nsString.h"
  53. #include "nsIChannel.h"
  54. #include "nsIProgressEventSink.h"
  55. #include "nsIInterfaceRequestor.h"
  56. #include "nsIInterfaceRequestorUtils.h"
  57. #include "nsIChannelEventSink.h"
  58. #include "nsISecurityEventSink.h"
  59. #include "nsISupportsPriority.h"
  60. #include "nsInt64.h"
  61. #include "nsCOMPtr.h"
  62. #include "pldhash.h"
  63.  
  64. struct nsRequestInfo;
  65. struct nsListenerInfo;
  66.  
  67. /****************************************************************************
  68.  * nsDocLoader implementation...
  69.  ****************************************************************************/
  70.  
  71. #define NS_THIS_DOCLOADER_IMPL_CID                 \
  72.  { /* 2f7f940d-d67e-40bc-b1ba-8c46de2b4cec */         \
  73.      0x2f7f940d,                                      \
  74.      0xd67e,                                          \
  75.      0x40bc,                                          \
  76.      {0xb1, 0xba, 0x8c, 0x46, 0xde, 0x2b, 0x4c, 0xec} \
  77.  }
  78.  
  79. class nsDocLoader : public nsIDocumentLoader, 
  80.                     public nsIRequestObserver,
  81.                     public nsSupportsWeakReference,
  82.                     public nsIProgressEventSink,
  83.                     public nsIWebProgress,
  84.                     public nsIInterfaceRequestor,
  85.                     public nsIChannelEventSink,
  86.                     public nsISecurityEventSink,
  87.                     public nsISupportsPriority
  88. {
  89. public:
  90.     NS_DEFINE_STATIC_IID_ACCESSOR(NS_THIS_DOCLOADER_IMPL_CID);
  91.  
  92.     nsDocLoader();
  93.  
  94.     virtual nsresult Init();
  95.  
  96.     static already_AddRefed<nsDocLoader> GetAsDocLoader(nsISupports* aSupports);
  97.     // Needed to deal with ambiguous inheritance from nsISupports...
  98.     static nsISupports* GetAsSupports(nsDocLoader* aDocLoader) {
  99.         return NS_STATIC_CAST(nsIDocumentLoader*, aDocLoader);
  100.     }
  101.  
  102.     // Add aDocLoader as a child to the docloader service.
  103.     static nsresult AddDocLoaderAsChildOfRoot(nsDocLoader* aDocLoader);
  104.  
  105.     NS_DECL_ISUPPORTS
  106.     NS_DECL_NSIDOCUMENTLOADER
  107.     
  108.     // nsIProgressEventSink
  109.     NS_DECL_NSIPROGRESSEVENTSINK
  110.  
  111.     NS_DECL_NSISECURITYEVENTSINK
  112.  
  113.     // nsIRequestObserver methods: (for observing the load group)
  114.     NS_DECL_NSIREQUESTOBSERVER
  115.     NS_DECL_NSIWEBPROGRESS
  116.  
  117.     NS_DECL_NSIINTERFACEREQUESTOR
  118.     NS_DECL_NSICHANNELEVENTSINK
  119.     NS_DECL_NSISUPPORTSPRIORITY
  120.  
  121.     // Implementation specific methods...
  122.  
  123.     // Remove aChild from our childlist.  This nulls out the child's mParent
  124.     // pointer.
  125.     nsresult RemoveChildLoader(nsDocLoader *aChild);
  126.     // Add aChild to our child list.  This will set aChild's mParent pointer to
  127.     // |this|.
  128.     nsresult AddChildLoader(nsDocLoader* aChild);
  129.     nsDocLoader* GetParent() const { return mParent; }
  130.  
  131. protected:
  132.     virtual ~nsDocLoader();
  133.  
  134.     virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
  135.  
  136.     // DocLoaderIsEmpty should be called whenever the docloader may be empty.
  137.     // This method is idempotent and does nothing if the docloader is not in
  138.     // fact empty.
  139.     void DocLoaderIsEmpty();
  140.  
  141.     PRBool IsBusy();
  142.  
  143.     void Destroy();
  144.     virtual void DestroyChildren();
  145.  
  146.     nsIDocumentLoader* ChildAt(PRInt32 i) {
  147.         return NS_STATIC_CAST(nsDocLoader*, mChildList[i]);
  148.     }
  149.  
  150.     nsIDocumentLoader* SafeChildAt(PRInt32 i) {
  151.         return NS_STATIC_CAST(nsDocLoader*, mChildList.SafeElementAt(i));
  152.     }
  153.  
  154.     void FireOnProgressChange(nsDocLoader* aLoadInitiator,
  155.                               nsIRequest *request,
  156.                               PRInt64 aProgress,
  157.                               PRInt64 aProgressMax,
  158.                               PRInt64 aProgressDelta,
  159.                               PRInt64 aTotalProgress,
  160.                               PRInt64 aMaxTotalProgress);
  161.  
  162.     void FireOnStateChange(nsIWebProgress *aProgress,
  163.                            nsIRequest* request,
  164.                            PRInt32 aStateFlags,
  165.                            nsresult aStatus);
  166.  
  167.     void FireOnStatusChange(nsIWebProgress *aWebProgress,
  168.                             nsIRequest *aRequest,
  169.                             nsresult aStatus,
  170.                             const PRUnichar* aMessage);
  171.  
  172.     void FireOnLocationChange(nsIWebProgress* aWebProgress,
  173.                               nsIRequest* aRequest,
  174.                               nsIURI *aUri);
  175.  
  176.     void doStartDocumentLoad();
  177.     void doStartURLLoad(nsIRequest *request);
  178.     void doStopURLLoad(nsIRequest *request, nsresult aStatus);
  179.     void doStopDocumentLoad(nsIRequest *request, nsresult aStatus);
  180.  
  181. protected:
  182.     // IMPORTANT: The ownership implicit in the following member
  183.     // variables has been explicitly checked and set using nsCOMPtr
  184.     // for owning pointers and raw COM interface pointers for weak
  185.     // (ie, non owning) references. If you add any members to this
  186.     // class, please make the ownership explicit (pinkerton, scc).
  187.   
  188.     nsCOMPtr<nsIRequest>       mDocumentRequest;       // [OWNER] ???compare with document
  189.  
  190.     nsDocLoader*               mParent;                // [WEAK]
  191.  
  192.     nsVoidArray                mListenerInfoList;
  193.     /*
  194.      * This flag indicates that the loader is loading a document.  It is set
  195.      * from the call to LoadDocument(...) until the OnConnectionsComplete(...)
  196.      * notification is fired...
  197.      */
  198.     PRBool mIsLoadingDocument;
  199.  
  200.     nsCOMPtr<nsILoadGroup>        mLoadGroup;
  201.     // We hold weak refs to all our kids
  202.     nsVoidArray                   mChildList;
  203.  
  204.     // The following member variables are related to the new nsIWebProgress 
  205.     // feedback interfaces that travis cooked up.
  206.     PRInt32 mProgressStateFlags;
  207.  
  208.     nsInt64 mCurrentSelfProgress;
  209.     nsInt64 mMaxSelfProgress;
  210.  
  211.     nsInt64 mCurrentTotalProgress;
  212.     nsInt64 mMaxTotalProgress;
  213.  
  214.     PLDHashTable mRequestInfoHash;
  215.  
  216.     /* Flag to indicate that we're in the process of restoring a document. */
  217.     PRBool mIsRestoringDocument;
  218.  
  219. private:
  220.     nsListenerInfo *GetListenerInfo(nsIWebProgressListener* aListener);
  221.  
  222.     PRInt64 GetMaxTotalProgress();
  223.  
  224.     nsresult AddRequestInfo(nsIRequest* aRequest);
  225.     nsRequestInfo *GetRequestInfo(nsIRequest* aRequest);
  226.     void ClearRequestInfoHash();
  227.     PRInt64 CalculateMaxProgress();
  228. ///    void DumpChannelInfo(void);
  229.  
  230.     // used to clear our internal progress state between loads...
  231.     void ClearInternalProgress(); 
  232. };
  233.  
  234. #endif /* nsDocLoader_h__ */
  235.